<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>练习2</title>
</head>
<body>
    <div id="app">

    </div>

    <!-- 引入react 核心库 -->
    <script type="text/javascript" src="./js/react.development.js"></script>
    <!-- 引入react-dom 用于支持react操作dom -->
    <script type="text/javascript" src="./js/react-dom.development.js"></script>
    <!-- 引入babel 用于讲jsx转成js -->
    <script type="text/javascript" src="./js/babel.min.js"></script>

    <!-- 组 件 -->
    <script type="text/babel">
        class Weather extends React.Component{
            constructor(props) {
                super(props)
                this.state = {
                    msg:'小红'
                }
                this.change = this.change.bind(this)
            }
            change(){
                this.setState({msg:'小明'})
            }
            render() {
                return (
                    <div>
                        <h1>我是{this.state.msg}</h1>
                        <button onClick={this.change}>小明</button>
                        <button onClick={this.change}>小张</button>
                    </div>
                )
            }
        }
        ReactDOM.render(<Weather/>,document.getElementById('app'))
    </script>
</body>

</html>